<?php

abstract class View
{
	protected $_appendBefore;
	protected $_appendAfter;
	private $_templateVars;
	public function __construct()
	{
		$this->_appendBefore=array("template/before.php");
		$this->_appendAfter=array("template/after.php");
		$this->_templateVars=array();
	}
	abstract protected function _getTemplate();
	protected function _assignVars()
	{
		//boo
	}
	public function show()
	{
		$this->_assignVars();
		extract($this->_templateVars);
		foreach($this->_appendBefore as $a)
		{
			require_once($a);
		}
		require_once($this->_getTemplate());
		foreach($this->_appendAfter as $a)
		{
			require_once($a);
		}
	}
	public function setVar($name, $value)
	{
		$this->_templateVars[$name]=$value;
	}
	public function getVar($name)
	{
		if(!$this->issetVar($name))
		{
			throw new ViewException(sprintf("Nincs ilyen változó (%s)!", $name));
		}
		return $this->_templateVars[$name];
	}
	public function issetVar($name)
	{
		return isset($this->_templateVars[$name]);
	}
}